Conversation
This comment has been minimized.
This comment has been minimized.
srittau
requested changes
Nov 1, 2022
| ] | ||
|
|
||
| _DataType: TypeAlias = bytes | IO[Any] | Iterable[bytes] | str | ||
| _DataType: TypeAlias = SupportsRead[bytes] | Iterable[ReadableBuffer] | ReadableBuffer |
Collaborator
There was a problem hiding this comment.
HTTPConnection.send() also allows str:
def request(self, method, url, body=None, headers={}, *,
encode_chunked=False):
"""Send a complete request to the server."""
self._send_request(method, url, body, headers, encode_chunked)
def _send_request(self, method, url, body, headers, encode_chunked):
# ...
# It also gets passed to _get_content_length(), which also supports str
# ...
if isinstance(body, str):
# RFC 2616 Section 3.7.1 says that text default has a
# default charset of iso-8859-1.
body = _encode(body, 'body')
self.endheaders(body, encode_chunked=encode_chunked)I think the best solution is just to add str to the body argument of request manually.
stdlib/http/server.pyi
Outdated
Comment on lines
57
to
59
| server: socketserver.BaseServer, | ||
| directory: str | None = ..., | ||
| index_pages: Sequence[str] | None = ..., |
Collaborator
There was a problem hiding this comment.
As directory is keyword only and I can't find index_pages anywhere (on 3.9):
Suggested change
| server: socketserver.BaseServer, | |
| directory: str | None = ..., | |
| index_pages: Sequence[str] | None = ..., | |
| server: socketserver.BaseServer, | |
| *, | |
| directory: str | None = ..., |
(directory is also passed to os.fspath() in later version (but not 3.7), but that's out of scope for this PR, since it needs overloads.)
Member
There was a problem hiding this comment.
index_pages is new in 3.12: python/cpython#31985. So we should branch on if sys.version_info >= (3, 12).
This comment has been minimized.
This comment has been minimized.
Contributor
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
srittau
approved these changes
Nov 3, 2022
AlexWaygood
added a commit
that referenced
this pull request
Nov 3, 2022
The stub currently implies that the index_pages parameter has been removed in 3.12. Actually, it was only added in 3.12 :) See python/cpython#31985. (This is a follow-up to #9055 — cc. @JelleZijlstra.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.